/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from 'react';
import defaultSetting from '../../../config/defaultSettings';
import { createFromIconfontCN } from '@ant-design/icons';

// 图标属性
interface TypeFontIconProps {
  type: string;
  style?: React.CSSProperties;
  className?: string;
}

// 框架内图标
const IconsMap = {};

// 字体图标 结合www.iconfont.cn网站使用
const IconFont = createFromIconfontCN({
  scriptUrl: defaultSetting.iconfontUrl,
});

const IconFontExtend: React.FC<TypeFontIconProps> = (props) => {
  const { type, ...rest } = props;
  const defaultIcon = IconsMap[type];

  return defaultIcon ? (
    React.cloneElement(defaultIcon, { ...rest })
  ) : (
    <IconFont type={type} {...rest} />
  );
};

export default IconFontExtend;
